package xdu.lz.stage2_design_pattern.chapter14_countDown_pattern;

public class CustomerCountDown {

    private final int total;

    private int counter = 0;

    public CustomerCountDown(int total) {
        this.total = total;
    }

    public void countDown(){
        synchronized (this){
            this.counter ++;
            notifyAll();
        }
    }

    public void await() throws InterruptedException {
        synchronized (this){
            while (counter != total){
                this.wait();
            }
        }
    }
}
